<?php
/**
 * Created by IntelliJ IDEA.
 * User: mosi
 * Date: 2020/4/28
 * Time: 10:57
 */

namespace app\admin\controller;


use app\admin\UserService;
use think\facade\Request;

class File extends UserService
{
    public function upload_img ()
    {
        // 获取表单上传文件 例如上传了001.jpg
        $files = Request::file();
        try {
            $savename = [];
            validate(['image'=>'fileSize:10240|fileExt:jpg,png|fileMime:image/jpeg,image/png'])->check($files);
            foreach($files as $file){
                $name = \think\facade\Filesystem::putFile( 'teal_name', $file);
                $savename[] = str_replace('\\','/',$name);
            }
            return jsonReturn(0, 'ok!',$savename);
        } catch (\think\exception\ValidateException $e) {
            return jsonReturn(80000, '文件上传失败!' . $e->getMessage());
        }
    }


}